#!/bin/sh
#description: Gtp start-stop script.
#by oilive
#DOMAN_HOME=gtp路径
GTP_HOME=/weblogic/TongGTP6.1/
#启停用户
WLS_OWNER=weblogic

num=`ps -ef|grep weblogic |grep -v grep |grep gtp |wc -l`
case "$1" in
	'start')
		if [[ $num -eq 0]];then
			su - $WLS_OWNER -c "cd ${GTP_HOME}; . ./setp; gtp; gtp -m;"
		else
			echo "gtp is running, so no need start!!!"
		fi
	;;
	'stop')
		if [[ $num -eq 0]];then
			echo "gtp not start, so no need stop!!!"
		else
			su -$WLS_OWNER -c "cd ${GTP_HOME}; ../setp; gtp -cstop -y; gtp -m -cstop;"
		fi
	;;
	'node')
		su -$WLS_OWNER -c "cd ${GTP_HOME}; ../setp; gtp_stat -node"
	;;
	'ps'
		if [[ $num -eq 0]];then
			echo "gtp not start, so doesn't have gtp proccess!!!"
		else
			echo "gtp is running, see next line for proccess content!!!"
			ps -ef|grep gtp
		fi
	;;
	'tail'
		tail -100f ${GTP_HOME}log/gtp.sys
	;;
esac
